package com.nageoffer.shortlink.project.dao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.nageoffer.shortlink.project.dao.entity.LinkLocaleStatsDO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;

/**
 * ClassName: LinkLocaleStatsDO
 * Package: com.nageoffer.shortlink.project.dao.mapper
 * Description:
 *
 * @Author Jetson
 * @Create 2024/10/29 12:01
 * @Version 1.0
 */
public interface LinkLocaleStatsMapper extends BaseMapper<LinkLocaleStatsMapper> {

    @Insert("INSERT INTO t_link_locale_stats (" +
            "        full_short_url,\n" +
            "        gid,\n" +
            "        date,\n" +
            "        cnt,\n" +
            "        country,\n" +
            "        province,\n" +
            "        city,\n" +
            "        adcode,\n" +
            "        create_time,\n" +
            "        update_time,\n" +
            "        del_flag)\n" +
            "VALUES (#{linklocaleStats.fullShortUrl},\n" +
            "        #{linklocaleStats.gid},\n" +
            "        #{linklocaleStats.date},\n" +
            "        #{linklocaleStats.cnt},\n" +
            "        #{linklocaleStats.country},\n" +
            "        #{linklocaleStats.province},\n" +
            "        #{linklocaleStats.city},\n" +
            "        #{linklocaleStats.adcode},\n" +
            "        NOW(),\n" +
            "        NOW(),\n" +
            "        0)\n" +
            "ON DUPLICATE KEY\n" +
            "    UPDATE cnt  = cnt + #{linklocaleStats.cnt};")
    void shortLinkLocaleState(@Param("linklocaleStats") LinkLocaleStatsDO linkLocaleStatsDO);
}
